<meta charset="utf-8"/>
<input id="num" />
<button onclick="f()">反转</button>
<script>
function f(){
var str="";
var array=num.value.split("");
for (var i=array.length-1;i>=0;i--){
  var s=array[i];
  str=str+s;
}
  document.write(str);
}
/*function f(){
  var str="";
  for(var i=num.value.length-1;i>=0;i--){
  var s=num.value[i];
  str=str+s;}
  document.write(str);
}*/
</script>